import Vue from 'vue'
import App from './App.vue'
import router from './router/router'
import VueResource from 'vue-resource'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import Cookies from 'js-cookie'

router.beforeEach((to, from, next) => {
  let Authorization = Cookies.get('Authorization') ? true:false;
  if (to.path == '/login'){
    if (Authorization) {
      next({path: '/'})
    }else {
      next();
    }
  }else {
    if (Authorization) {
      next()
    }else {
      next({path: '/login'});
    }
  }
});
Vue.use(VueResource)
Vue.use(ElementUI)


Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
